<template>
	<view class="app" style="background-image: url(https://gnzxwylz.xlygrcw.com/upload/GNZX/motion/1.png);">
		<view class="app-1">
			<view class="app-11">
				<view class="">
					<text>{{ motionData.applyName }}</text>
					<text>提案分类：{{ motionData.typeName }}</text>
					<text>电话：{{ motionData.phone }}</text>
					<text>邮编：{{ motionData.mail }}</text>
					<text>是否联名：{{ motionData.isJointlySigned == 0 ? '不联名' : '联名' }}</text>
					<text>建议承办单位： {{ motionData.departmentName }}</text>
				</view>
			</view> 
			<view class="app-12">
				<text>联名委员</text>
				<text>{{ motionData.jointlySigned||'暂无' }}</text>
			</view>
			<view class="app-12">
				<text>通讯地址（单位）</text>
				<text>{{ motionData.address }}</text>
			</view>
			<view class="app-12">
				<text>案题</text>
				<text>{{ motionData.title }}</text>
			</view>
			<view class="app-12">
				<text>内容</text>
				<u-parse :html="motionData.content"></u-parse>
			</view>
			<view class="app-12" v-if="motionData.imgUrl">
				<text>图片</text>
				<view class=""><image v-for="(item, index) in motionData.imgUrl" :key="index" :src="item | imgUrl" mode="aspectFill"></image></view>
			</view>
		</view>
		<view class="app-title"><text>提案结果</text></view>
		<view class="app-2">
			<view class="">
				<text>提案时间</text>
				<text>{{ motionData.createDate | dateFilters }}</text>
			</view>
			<!-- 		<view class="">
				<text>建议承办单位</text>
				<text>{{motionData.departmentName}}</text>
			</view>
			<view class="">
				<text>审查时间</text>
				<text>2020.01.01</text>
			</view> -->
			<view class="">
				<text>审查意见</text>
				<text class="on1" v-if="motionData.status == 0">待审核</text>
				<text class="on1" v-if="motionData.status == 1">不立案</text>
				<text class="on1" v-if="motionData.status == 2">立案</text>
				<text class="on1" v-if="motionData.status == 3">来信处理</text>
				<text class="on1" v-if="motionData.status == 4">待回复</text>
				<text class="on1" v-if="motionData.status == 5">待评价</text>
				<text class="on1" v-if="motionData.status == 6">已评价</text>
			</view>
			<view class="">
				<text>转科局</text>
				<text>{{ motionData.departmentName }}</text>
			</view>
			<view class=""><text>回复意见</text></view>
			<view class="">
				<text>{{ motionData.remark ||'暂无'}}</text>
			</view>
			<!-- <view class="">
				<text>评价时间</text>
				<text>2020.01.01</text>
			</view> -->
			<view class="" v-if="motionData.status == 6">
				<text>满意度</text>
				<text class="on" v-if="motionData.appraise == 1">满意</text>
				<text class="on" v-else-if="motionData.appraise == 2">基本满意</text>
				<text class="on" v-else-if="motionData.appraise == 3">不满意</text>
				<text class="on" v-else>未评价</text>
			</view>

			<view class="" v-if="motionData.status == 6"><text>评价内容</text></view>
			<view class="" v-if="motionData.status == 6">
				<text>{{ motionData.appraiseInfo }}</text>
			</view>
		</view>
		<view class="app-title" v-if="motionData.status == 5"><text>评价</text></view>
		<view class="app-3" v-if="motionData.status == 5">
			<view class="app-31">
				<text>满意度</text>
				<view class="">
					<picker @change="bindPickerChange" :value="motionData.appraise" :range="array">
						<view class="app-311">
							<text>{{ array[motionData.appraise - 1]||'请选择' }}</text>
							<text class="iconfont">&#xe60d;</text>
						</view>
					</picker>
				</view>
			</view>
			<view class="app-32">
				<text>内容</text>
				<view class=""><u-input v-model="motionData.appraiseInfo" type="textarea" /></view>
			</view>
			<view class="btn"><text @tap='onSumbit'>提交</text></view>
		</view>
	</view>
</template>

<script>
	import validate from '../../utils/validate.js'
export default {
	data() {
		return {
			array: ['满意', '基本满意', '不满意'],
			formData: {},
			user: {},
			motionData: {}
		};
	},
	components: {},
	onLoad(option) {
		console.log(option);
		this.user = uni.getStorageSync('gnzx_users');
		this.getMotionInfo(option);
	},
	methods: {
		bindPickerChange(e) {
			this.motionData.appraise =parseInt(e.detail.value)  +1;
			console.log(this.motionData.appraise)
		},
		getMotionInfo(param) {
			var _this = this;
			this.request({
				url: this.interfaces.getMintionInfo,
				data: param,
				method: 'POST',
				success: res => {
					_this.motionData = res.data;
					if(_this.motionData.imgUrl.length>0){
						_this.motionData.imgUrl = _this.motionData.imgUrl.split(',');
					}
					
					console.log(_this.motionData.imgUrl)
				},
				fail(e) {
					uni.showToast({
						title: '获取失败'
					});
				}
			});
		},
		onSumbit(){
			if(validate.isEmptyVal(this.motionData.appraise)){
				uni.showToast({
					title:'请选择满意度...',
					icon:'none'
				})
				return false
			}
			var _this = this;
			this.motionData.status = 6
			this.motionData.imgUrl =this.motionData.imgUrl.join(',')
			this.request({
				url: this.interfaces.getMintionAppraise,
				data: this.motionData,
				method: 'POST',
				success: res => {
					uni.showToast({
						title:res.data,
						icon:'none'
					})
					console.log(res)
				},
				fail(e) {
					uni.showToast({
						title: '获取失败'
					});
				}
			});
		}
	}
};
</script>

<style lang="scss">
@import './dec.scss';
</style>
